package org.msfj.admin.data.controller;

import org.msfj.common.base.BaseController;
import org.msfj.common.feign.SubmailApi;
import org.msfj.common.model.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.msfj.common.submail.SubMailTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 系统短信模板信息controller
 * @Author: like
 * @Email: like@deyatong.com
 * @Date: 2017-08-24 16:05:31
 * @Version: 1.0
 * @Created in idea by autoCode
 */
@Api(value = "系统短信模板信息接口", tags = "系统短信模板信息接口")
@RestController
@RequestMapping("data/messageTemplate")
public class MessageTemplateController extends BaseController{

    @Autowired
    SubmailApi submailApi;
    /**
     * 添加系统短信模板信息
     *
     * @param subMailTemplate
     * @return CommonResult.ok(SubMailTemplate)
     */
    @RequestMapping("/add")
    @ApiOperation(value = "添加系统短信模板信息",notes = "添加系统短信模板信息")
    @ApiImplicitParam(value = "短信模板对象",name = "subMailTemplate",dataType = "org.msfj.admin.vo.SubMailTemplate",paramType = "query")
    public CommonResult addMessageTemplate(SubMailTemplate subMailTemplate){
        CommonResult<SubMailTemplate> subMailTemplate1 = submailApi.insertTemplate(subMailTemplate);
        return subMailTemplate1;
    }

    /**
     * 修改系统短信模板信息
     *
     * @param subMailTemplate
     * @return CommonResult.ok(SubMailTemplate)
     */
    @RequestMapping("/edit")
    @ApiOperation(value = "修改系统短信模板信息",notes = "修改系统短信模板信息")
    @ApiImplicitParam(value = "subMailTemplate",name = "subMailTemplate",dataType = "org.msfj.admin.vo.SubMailTemplate",paramType = "query")
    public CommonResult editMessageTemplate(SubMailTemplate subMailTemplate){
        CommonResult<Boolean> booleanCommonResult = submailApi.updateTemplate(subMailTemplate);
        return CommonResult.ok(booleanCommonResult);
    }

    /**
     * 真实删除系统短信模板信息
     *
     * @param subMailTemplate
     * @return CommonResult.ok()
     */
    @RequestMapping("/delete")
    @ApiOperation(value = "真实删除系统短信模板信息",notes = "真实删除系统短信模板信息")
    @ApiImplicitParam(value = "subMailTemplate",name = "subMailTemplate",dataType = "org.msfj.admin.vo.SubMailTemplate",paramType = "query")
    public CommonResult deleteMessageTemplate(SubMailTemplate subMailTemplate){
        return CommonResult.ok(submailApi.deleteTemplate(subMailTemplate));
    }

    /**
     * 根据搜索参数查找所有系统短信模板信息
     *
     * @return CommonResult.ok(List<SubMailTemplate>)
     */
    @RequestMapping("/list")
    @ApiOperation(value = "根据搜索参数查找所有系统短信模板信息",notes = "根据搜索参数查找所有系统短信模板信息")
    public CommonResult getAllMessageTemplate(){
        CommonResult<List<SubMailTemplate>> templateList = submailApi.getTemplateList();
        return templateList;
    }
}
